class Solution(object):
    def removeCoveredIntervals(self, intervals):
        intervals.sort(key=lambda x: (x[0], -x[1]))
        n = len(intervals)
        last = intervals[0][1]
        ans = n
        for i in range(1, n):
            if intervals[i][1] <= last:
                ans -= 1
            else:
                last = intervals[i][1]
        return ans

